import {req_get, req_post} from "@/request/cssdrequest";
import {R} from "@/type/dto/R";
import {RP} from "@/type/dto/RP";
import {TrainingLessonsInfoVO} from "@/type/vo/TrainingLessonsInfoVO";
import {TrainingUserInfoVO} from "@/type/vo/TrainingUserInfoVO";

export async function api_listTrain(trainingName: string | null,
                                    startDate: string,
                                    endDate: string,
                                    trainingTeacher: string,
                                    page: number,
                                    limit: number) {
    const data = await req_get('/training/lesson', {
        trainingName,
        startDate,
        endDate,
        trainingTeacher,
        page,
        limit
    });
    //转成我要的json
    console.log('data:', data);
    return JSON.parse(data) as R<RP<TrainingLessonsInfoVO>>;
}

export async function api_addTrain(trainingName: string,
                                   startTime: number | null,
                                   endTime: number | null,
                                   teacher: string,
                                   description: string,
                                   barcode: string
) {

    const data = await req_post('/training/lesson', {
        trainingName,
        startTime,
        endTime,
        teacher,
        description,
        barcode
    });
    //转成我要的json
    console.log('data:', data);
    return JSON.parse(data) as R<string>;
}

export async function api_pageTrainUser(trainingId: string,
                                         page: number,
                                         limit: number

) {

    const data = await req_get('/training/lesson/user', {
        trainingId,
        page,
        limit
    });
    //转成我要的json
    console.log('data:', data);
    return JSON.parse(data) as R<RP<TrainingUserInfoVO>>;
}

// export async function api_deleteExam(deleteId: string) {
//
//     const data = await req_delete('/exam', {
//         id:deleteId
//     });
//     //转成我要的json
//     console.log('data:', data);
//     return JSON.parse(data) as R<object>;
// }
//
//
// export async function api_getExamInfo(examId: string) {
//     const data = await req_get('/exam/all', {
//         id: examId
//     });
//     //转成我要的json
//     console.log('data:', data);
//     return JSON.parse(data) as R<ExamVO>;
// }
//
// export async function api_createExam(examType: number,
//                                      creatorCode: string,
//                                      title: string) {
//
//     const data = await req_post('/exam', {
//         examType,
//         creatorCode,
//         title,
//         status: 0,
//         totalScore: 0
//     });
//     //转成我要的json
//     console.log('data:', data);
//     return JSON.parse(data) as R<string>;
// }
//
// export async function api_updateExam(exam:ExamVO) {
//
//     const data = await req_put('/exam', exam);
//     //转成我要的json
//     console.log('data:', data);
//     return JSON.parse(data) as R<string>;
// }
// export async function api_publicExam(officeExam:PublishExamInfo) {
//
//     const data = await req_put('/exam/publish', officeExam);
//     //转成我要的json
//     console.log('data:', data);
//     return JSON.parse(data) as R<string>;
// }
